<template>
  <div style="height: 100%;background-color:white ;padding: 5px">
    <div>
      <div style="display: inline-block">
        <el-button @click="goBack" icon="el-icon-back" type="text">返回</el-button>
      </div>
      <div style="display: inline-block">|</div>
      <div style="display: inline-block;">
        <div style="padding-bottom: 15px;">
          <span style="font-family: 'Microsoft YaHei',sans-serif;display: inline-block">日志</span>
        </div>
      </div>
      <div style="border-bottom: solid 1px #C9C9C9;"></div>
    </div>
    <div style="margin-top: 10px">
      公式名称:
      <label v-html="knowledgeName"></label>
    </div>
    <el-row>
      <el-table highlight-current-row :data="logTableData" :height="tableHeight" border stripe style="width: 100%;margin-top: 10px">
        <el-table-column label="操作人" min-width="400" prop="createdBy"></el-table-column>
        <el-table-column :formatter="row => CONST.HISTORY_OPERATE_STATUS[row.operate]" label="操作动作" min-width="180"
                         prop="operate">
        </el-table-column>
        <el-table-column :formatter="row => row.oresult === 0 ? '成功' : '失败'" label="操作结果" min-width="100"
                         prop="oresult">
        </el-table-column>
        <el-table-column :formatter="dateFormat" label="记录时间" min-width="150" prop="updatedTime">
        </el-table-column>
      </el-table>
    </el-row>
  </div>
</template>


<script>
  import moment from "moment";

  export default {
    name: "CalculatorLog",
    data() {
      return {
        knowledgeName: '',
        logTableData: [],
        tableHeight: ''
      }
    },
    methods: {
      goBack: function () {
        this.$router.go(-1)
      },
      dateFormat: function (row, column) {
        const date = row[column.property]
        if (date == undefined) {
          return ''
        }
        return moment(date).format("YYYY-MM-DD  HH:mm:ss")
      }
    },
    mounted: function () {
      this.axios.get('/pmph/action/medicalCalculator/selectLogData', {
        params: {
          id: this.$route.query.id
        }
      }).then((response) => {
        console.log(response)
        this.logTableData = response.data;
        this.knowledgeName = response.data[0].knowledgeName;

      }).catch((error) => {
        console.error(error);
        this.logTableData = [];
        this.noData = true;
        this.$message.error("未能请求到数据");
      })
    },
    created() {
      this.tableHeight = CONST.WORKSPACE_HEIGHT - 160 + "px"
    }
  }

</script>

<style scoped>

</style>
